package org.hagopa.games.moneypool.msgs.ContentTypes.service;

import java.nio.ByteBuffer;

import org.hagopa.games.moneypool.msgs.IMsgContent;

public class PlayerType implements IMsgContent{
	/**
	 * 
	 */
	private int type;
	private int playerId = 0;
	private String strType = null;
	private int marshalledSize = 0;
	
	public int getType() {
		return type;
	}
	public void setType(int type) {
		this.type = type;
	}
	public String getStrType() {
		return strType;
	}
	public void setStrType(String strType) {
		this.strType = strType;
	}
	public int getPlayerId() {
		return playerId;
	}
	public void setPlayerId(int playerId) {
		this.playerId = playerId;
	}
	
	public int getSize() {
		// TODO Auto-generated method stub
		return marshalledSize;
	}
	
	public byte[] marshallToByte() {
		ByteBuffer dataArray = ByteBuffer.allocate(128);
		
		byte [] bytes = new byte[64];
		
		dataArray.putInt(this.playerId);
		dataArray.putInt(this.type);
		this.marshalledSize = 8;
		dataArray.rewind();
		dataArray.get(bytes,0,bytes.length);
		return bytes;
	}
	
	public boolean unmarshallFromByte(byte[] content) {
		ByteBuffer dataArray = ByteBuffer.wrap(content);
		if(null == dataArray)
		{
			return false;
		}
		dataArray.clear();
		//dataArray.rewind();
		this.playerId = dataArray.getInt();
		this.type = dataArray.getInt();
		return true;
	}

    public String getConcatContent() {
        String outstr = null;
        outstr = String.valueOf(this.playerId) + String.valueOf(this.type);
        return outstr;
    }
}
